package com.shadow.bd;

import com.shadow.bd.bean.A;
import com.shadow.bd.bean.B;
import com.shadow.bd.bean.C;
import com.shadow.bd.config.MyConfig;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Date;

/**
 * @author VernHe
 * @date 2021年11月27日 17:02
 */
public class beanDefinitionTest {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

		context.register(MyConfig.class);

		GenericBeanDefinition c = new GenericBeanDefinition();
		c.setBeanClass(C.class);
		// 注入Date类型的数据
		c.getPropertyValues().add("date",new Date());

//		c.setDependencyCheck(AbstractBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
		/**
		 * Simple
		 *
		 * public static boolean isSimpleValueType(Class<?> type) {
		 * 		return (Void.class != type && void.class != type &&
		 * 				(ClassUtils.isPrimitiveOrWrapper(type) ||
		 * 				Enum.class.isAssignableFrom(type) ||
		 * 				CharSequence.class.isAssignableFrom(type) ||
		 * 				Number.class.isAssignableFrom(type) ||
		 * 				Date.class.isAssignableFrom(type) ||
		 * 				Temporal.class.isAssignableFrom(type) ||
		 * 				URI.class == type ||
		 * 				URL.class == type ||
		 * 				Locale.class == type ||
		 * 				Class.class == type));
		 *        }
		 */
		c.setDependencyCheck(AbstractBeanDefinition.DEPENDENCY_CHECK_SIMPLE);


		context.registerBeanDefinition("c",c);
		context.refresh();

		System.out.println((context.getBean(C.class)).getB());
		System.out.println(c.getAutowireMode());
		System.out.println(c.getDependencyCheck());

//		System.out.println(context.getBean(B.class));


	}
}
